var orderId;
apiready = function() {

	orderId = api.pageParam.repairId;
	if (!orderId) {
		api.closeWin();
	}

	$api.do_post('/api/ropertyRepair/info', {
		body: JSON.stringify({
			id: orderId
		})
	}, function(repairData) {
		console.dir(repairData)
		if (repairData) {
			$('#repairItem').append(repairData.repairItem);
			$('#repairItem').append(repairData.status);
			$('#amount').append(repairData.amount);
			$('#repairContent').append(repairData.repairContent);
			$('#ownerName').append(repairData.owerName);
			$('#mobile').append(repairData.account);
			bindVal("#confirmTime", repairData.confirmTime);
			bindVal("#repairMan", repairData.repairMan || "");
			$('#')
			console.error(repairData)
			var data = JSON.parse(repairData);
		}
	})



};

function bindVal(el, val) {
	$(el).append(val);
}



$(function() {
	//提交评价
	$("#sub_btn").click(function() {
		var repairId = $("#repairId").val();
		var evaluate = $("#evaluate").val();
		var serviceSpeed = $("#serviceSpeed").attr("data");
		var quality = $("#quality").attr("data");
		var serviceAttitude = $("#serviceAttitude").attr("data");

		var data = 'repairId=' + repairId;
		data += '&evaluate=' + evaluate;
		data += '&serviceSpeed=' + serviceSpeed;
		data += '&quality=' + quality;
		data += '&serviceAttitude=' + serviceAttitude;

		$("#sub_btn").button("loading");

		$api.do_post("/api/ropertyRepair/evaluate", {
			body: JSON.stringify({
				repairId: orderId,
				serviceSpeed: serviceSpeed,
				quality: quality,
				serviceAttitude: serviceAttitude,
				evaluate: evaluate
			})
		}, function(result) {
			if (result.code == "0") {
				$("#errmsg").text("评价成功!");
				$('#my-alert').modal({
					relatedTarget: this,
				});
				setTimeout(function(){
					api.closeWin();
				}, 1500);
			} else {
				$("#errmsg").text(result.datas);
				$('#my-alert').modal({
					relatedTarget: this,
				});
			}
		})

	});

	$(".appraisal_set b").click(function() {
		$(this).parent().find("i").removeClass("set_on_icon");
		$(this).find("i").addClass("set_on_icon");
		$(this).parent().attr("data", $(this).index());
	});
});